#!/bin/sh
yum install vim -y
# 下载vim插件管理器
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

# 下载vim配置
curl https://gitee.com/XYLongzzZ/msh/raw/master/file/vimrc -o ~/.vimrc

# 下载插件
yum install git -y
git clone https://gitee.com/XYLongzzZ/vim-plug.git ~/.vim/plugged --recurse-submodules

# 安装nodejs，COC需要
yum install nodejs -y
curl -sL install-node.now.sh/lts | bash -s -- -y
# 安装ripgrep, LeaderF使用
curl http://github.com.cnpmjs.org/BurntSushi/ripgrep/releases/download/12.1.1/ripgrep-12.1.1-x86_64-unknown-linux-musl.tar.gz -L -o -|tar -zxvf - -C /usr/share
ln -svf /usr/share/ripgrep-12.1.1-x86_64-unknown-linux-musl/rg /usr/local/bin/rg

# 开启终端256色
echo 'if [ "$TERM"=="xterm" ]; then' >> ~/.bashrc
echo '    export TERM=xterm-256color' >> ~/.bashrc
echo 'fi' >> ~/.bashrc
source ~/.bashrc

# 修改主题
echo 'hi PMenu ctermfg=0 ctermbg=242 guifg=black guibg=darkgrey' >> /usr/share/vim/vim8*/colors/industry.vim
echo 'hi PMenuSel ctermfg=242 ctermbg=8 guifg=darkgrey guibg=black' >> /usr/share/vim/vim8*/colors/industry.vim

# 编译YCM
cd ~/.vim/plugged/YouCompleteMe
./install.py --clang-completer
./install.py --clangd-completer

YCM_PATH=~/.vim/plugged/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py
GCC_VERSION=$(gcc --version|head -1|awk '{print $3}')
MACHINE=$(uname -m)-linux-gnu
sed -i  "/^'c++'/a\'-isystem',\n'/usr/include/c++/$GCC_VERSION/bits'," $YCM_PATH
sed -i  "/^'c++'/a\'-isystem',\n'/usr/include/c++/$GCC_VERSION'," $YCM_PATH
sed -i  "/^'c++'/a\'-isystem',\n'/usr/lib/gcc/$MACHINE/$GCC_VERSION/include'," $YCM_PATH
sed -i  "/^'c++'/a\'-isystem',\n'/usr/include/$MACHINE'," $YCM_PATH
sed -i  "/^'c++'/a\'-I',\n'/usr/include'," $YCM_PATH